package cn.tedu.jsd2207csmall.passport.config;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;

@Slf4j
@Configuration
public class ValidationConfiguration {

    public ValidationConfiguration() {
        log.debug("创建配置类对象:ValidationConfiguration");
    }

    @Bean
    public Validator validation(){
        return  Validation.byProvider(HibernateValidator.class)
                          .configure()
                          .failFast(true)
                          . buildValidatorFactory()
                          . getValidator();
    }
}
